package cineplanet.modelo;

import java.io.Serializable;
import javax.persistence.*;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;


/**
 * The persistent class for the horario database table.
 * 
 */
@Entity
@Table(name="horario")
@NamedQueries({@NamedQuery(name = "Horario.findAll", query = "SELECT h FROM Horario h"),
	@NamedQuery(name = "Horario.findByIdHorario", query = "SELECT h FROM Horario h WHERE h.idHorario = :idHorario"),
	@NamedQuery(name = "Horario.findByEstado", query = "SELECT h FROM Horario h WHERE h.estado = :estado"),
	@NamedQuery(name = "Horario.findByFechaProyeccion", query = "SELECT h FROM Horario h WHERE h.fechaProyeccion = :fechaProyeccion"),
	@NamedQuery(name = "Horario.findByHora", query = "SELECT h FROM Horario h WHERE h.hora = :hora"),
	@NamedQuery(name = "Horario.findByPrecio", query = "SELECT h FROM Horario h WHERE h.precio = :precio")
})
public class Horario implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idHorario")
	private Integer idHorario;
	@Column(name = "estado")
	private byte estado;
    @Temporal( TemporalType.TIMESTAMP)
    @Column(name = "fechaProyeccion")
	private Date fechaProyeccion;
    @Column(name = "hora")
	private String hora;
    @Column(name = "precio")
	private BigDecimal precio;

	//bi-directional many-to-one association to Cine
	@JoinColumn(name = "idCine", referencedColumnName = "idCine", insertable = false, updatable = false)
    @ManyToOne(optional = false)
	private Cine idCine;

	//bi-directional many-to-one association to Pelicula
	@JoinColumn(name = "idPelicula", referencedColumnName = "idPelicula", insertable = false, updatable = false)
    @ManyToOne(optional = false)
	private Pelicula idPelicula;

	//bi-directional many-to-one association to Venta
//	@OneToMany(mappedBy="horario")
//	private Set<Venta> ventas;
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "idHorario")
	private Collection<Venta> ventaCollection;

    public Horario() {
    }

	public int getIdHorario() {
		return this.idHorario;
	}

	public void setIdHorario(int idHorario) {
		this.idHorario = idHorario;
	}

	public byte getEstado() {
		return this.estado;
	}

	public void setEstado(byte estado) {
		this.estado = estado;
	}

	public Date getFechaProyeccion() {
		return this.fechaProyeccion;
	}

	public void setFechaProyeccion(Date fechaProyeccion) {
		this.fechaProyeccion = fechaProyeccion;
	}

	public String getHora() {
		return this.hora;
	}

	public void setHora(String hora) {
		this.hora = hora;
	}

	public BigDecimal getPrecio() {
		return this.precio;
	}

	public void setPrecio(BigDecimal precio) {
		this.precio = precio;
	}

		public void setVentaCollection(Collection<Venta> ventaCollection) {
		this.ventaCollection = ventaCollection;
	}

	public Collection<Venta> getVentaCollection() {
		return ventaCollection;
	}
	@Override
    public int hashCode() {
        int hash = 0;
        hash += (idHorario != null ? idHorario.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Horario)) {
            return false;
        }
        Horario other = (Horario) object;
        if ((this.idHorario == null && other.idHorario != null) || (this.idHorario != null && !this.idHorario.equals(other.idHorario))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cineplanet.modelo.Horario[idHorario=" + idHorario + "]";
    }

	public void setIdCine(Cine idCine) {
		this.idCine = idCine;
	}

	public Cine getIdCine() {
		return idCine;
	}

	public void setIdPelicula(Pelicula idPelicula) {
		this.idPelicula = idPelicula;
	}

	public Pelicula getIdPelicula() {
		return idPelicula;
	}
}